﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using IterationLife.UserProfiles.Models;
using Util.Domains;
using Util.Domains.Auditing;

namespace IterationLife.Educations.Models {
    /// <summary>
    /// 课程表
    /// </summary>
    [Description( "课程表" )]
    public partial class CurriculumSchedule : AggregateRoot<CurriculumSchedule>,IDelete,IModificationAudited {
        /// <summary>
        /// 初始化课程表
        /// </summary>
        public CurriculumSchedule() : this( Guid.Empty ) {
        }

        /// <summary>
        /// 初始化课程表
        /// </summary>
        /// <param name="id">课程表标识</param>
        public CurriculumSchedule( Guid id ) : base( id ) {
        }

        /// <summary>
        /// 用户资料编号
        /// </summary>
        public Guid? UserProfileId { get; set; }
        /// <summary>
        /// 科目编号
        /// </summary>
        public Guid? SubjectId { get; set; }
        /// <summary>
        /// 年级
        /// </summary>
        [Required(ErrorMessage = "年级不能为空")]
        public int Grade { get; set; }
        /// <summary>
        /// 学期
        /// </summary>
        [Required(ErrorMessage = "学期不能为空")]
        public Guid Semester { get; set; }
        /// <summary>
        /// 星期
        /// </summary>
        [Required(ErrorMessage = "星期不能为空")]
        public int Day { get; set; }
        /// <summary>
        /// 节数
        /// </summary>
        [Required(ErrorMessage = "节数不能为空")]
        public int Node { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreationTime { get; set; }
        /// <summary>
        /// 用户编号
        /// </summary>
        [Required(ErrorMessage = "用户编号不能为空")]
        public Guid UserId { get; set; }
        /// <summary>
        /// 最后修改时间
        /// </summary>
        public DateTime? LastModificationTime { get; set; }
        /// <summary>
        /// 最后修改人
        /// </summary>
        public Guid? LastModifierId { get; set; }
        /// <summary>
        /// 是否删除
        /// </summary>
        [Required(ErrorMessage = "是否删除不能为空")]
        public bool IsDeleted { get; set; }
        
        /// <summary>
        /// 科目
        /// </summary>
        public virtual Subject Subject { get; set; }
        
        /// <summary>
        /// 用户资料
        /// </summary>
        public virtual UserProfile UserProfile { get; set; }
        
        /// <summary>
        /// 添加描述
        /// </summary>
        protected override void AddDescriptions() {
            AddDescription( "课程表编号", Id );
            AddDescription( "用户资料编号", UserProfileId );
            AddDescription( "科目编号", SubjectId );
            AddDescription( "年级", Grade );
            AddDescription( "学期", Semester );
            AddDescription( "星期", Day );
            AddDescription( "节数", Node );
            AddDescription( "创建时间", CreationTime );
            AddDescription( "用户编号", UserId );
            AddDescription( "最后修改时间", LastModificationTime );
            AddDescription( "最后修改人", LastModifierId );
        }
        
        /// <summary>
        /// 添加变更列表
        /// </summary>
        protected override void AddChanges( CurriculumSchedule newEntity ) {
            AddChange( "Id", "课程表编号", Id, newEntity.Id );            
            AddChange( "UserProfileId", "用户资料编号", UserProfileId, newEntity.UserProfileId );
            AddChange( "SubjectId", "科目编号", SubjectId, newEntity.SubjectId );
            AddChange( "Grade", "年级", Grade, newEntity.Grade );
            AddChange( "Semester", "学期", Semester, newEntity.Semester );
            AddChange( "Day", "星期", Day, newEntity.Day );
            AddChange( "Node", "节数", Node, newEntity.Node );
            AddChange( "CreationTime", "创建时间", CreationTime, newEntity.CreationTime );
            AddChange( "UserId", "用户编号", UserId, newEntity.UserId );
            AddChange( "LastModificationTime", "最后修改时间", LastModificationTime, newEntity.LastModificationTime );
            AddChange( "LastModifierId", "最后修改人", LastModifierId, newEntity.LastModifierId );
        }
    }
}